window.onload = function() {
  var vm = new Vue({
    el: "#layout-w",
    data: {
      addressList: [], // 市列表
      areaList: [], //区列表
      popup: {}, //弹窗对象
      form: {},
      isDisable: true
    },
    created: function() {
      this.popup = new auiPopup();
    },
    methods: {
      // 获取区县
      getCommonCityItems: function() {
        var _this = this;
        house_server.getCommonCityItems({ cityId: "1" }, function(response) {
          _this.addressList = response.data.params;
          _this.areaList = _this.addressList[0].towns;
          _this.form.cityId = _this.addressList[0].item_name;
          _this.form.townId = _this.areaList[0].item_name;
        });
      },
      // 初始化弹窗
      showPopup: function() {
        this.popup.show(document.getElementById("bottom"));
        this.getCommonCityItems();
      },
      //   提交
      create: function() {
        // for(var key in this.form){
        //     if(this.form[key]){
        //         this.isDisable = true;
        //     }else{
        //         this.isDisable = false;
        //         return;
        //     }
        // }
        var _this = this;
        this.form.type = "3";
        house_server.getDevelopersCreate(this.form, function(res) {
          if (res.code == 200) {
            _this.popup.hide(document.getElementById("created"));
            apiready = function() {
              api.parseTapmode();
            };
            var toast = new auiToast({});
            _this.form = {};
            toast.success({
              title: "提交成功",
              duration: 2000
            });
          }
        });
      }
    },
    ready: function() {
      var _this = this;
      $("#city").on("change", function() {
        var index = $(this)
          .find("option:selected")
          .attr("data-index");
        _this.form.cityId = $(this)
          .find("option:selected")
          .val();
        _this.areaList = _this.addressList[index].towns;
      });
    },
    watch: {
      // "form":function(val, oldVal){
      //     console.log('1',val, oldVal)
      // },
      // "form.cityId":{
      //     hangler:function(val, oldVal){
      //         console.log(val, oldVal)
      //     },
      //     deep: true
      // }
    }
  });
};
